/**
* project3D Engine
* Simple material that renders object in wireframe
* @author John Sword
* @version 2 - AS3
*/

package engine.materials
{
	
	import engine.materials.Material;
	import engine.geom.Face;
	import flash.display.Sprite;
	import flash.display.Graphics;
	
	public class Wireframe extends Material
	{

		private var alpha:Number = 0;
		
		public function Wireframe ()
		{
			super( null );
			if ( !wireSize ) wireSize = 1;
			if ( !wireAlpha ) wireAlpha = 1; 
		}
		
		public override function render ( face:Face, screen:Sprite ) : void
		{
			// get vertices x,y positions
			//var verts:Array = face.vertices;
			/*
			var x0:Number = face.v1.screen.x,
			y0:Number = face.v1.screen.y,
			x1:Number = face.v2.screen.x,
			y1:Number = face.v2.screen.y,
			x2:Number = face.v3.screen.x,
			y2:Number = face.v3.screen.y;
			*/
			var x0:Number 	= face.v1.screen.x,
			y0:Number 		= face.v1.screen.y;
			
			// Draw triangle
			var g:Graphics = screen.graphics;
			
			g.beginFill( wireColor, alpha );
			g.lineStyle( wireSize, wireColor, wireAlpha);

			g.moveTo( x0, y0 );
			g.lineTo( face.v2.screen.x, face.v2.screen.y );
			g.lineTo( face.v3.screen.x, face.v3.screen.y );
			g.lineTo( x0, y0 );

			g.lineStyle();
		}
		
	}
	
}
